package com.diy.sigmund.diycommon.test.controller.other;

import com.diy.sigmund.diycommon.entity.ResultMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.framework.AopContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ylm-sigmund
 * @since 2021/10/23 19:41
 */
@RestController
public class AopContextTestController {

    private static final Logger log = LoggerFactory.getLogger(AopContextTestController.class);

    @GetMapping("/AopContextTestController/test")
    public ResultMsg test() {
        log.info("test");
        AopContextTestController aopContextTestController = (AopContextTestController) AopContext.currentProxy();
        aopContextTestController.test1();
        // if (3 == 3) {
        //     throw new DiyRuntimeException();
        // }
        return ResultMsg.success();
    }

    public ResultMsg test1() {
        log.info("test1");
        return ResultMsg.success();
    }
}
